package data;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.Properties;
import java.util.ResourceBundle;

import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.Mongo;
import com.mongodb.MongoException;

public class Data {
	static Mongo m = null;

	public static DBCollection data(String name) throws IOException {
		File f = new File("configfeed.properties");
		Properties pro = new Properties();
		FileInputStream in = new FileInputStream(f);
		pro.load(in);
		if (m == null) {
			try {
				m = new Mongo(pro.getProperty("host"));
			} catch (UnknownHostException e) {
				e.printStackTrace();
			} catch (MongoException e) {
				e.printStackTrace();
			}
		}
		DB db = m.getDB(pro.getProperty("database"));

		DBCollection coll = db.getCollection(name);
		return coll;
	}
}
